package com.zhr.tea.view.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.zhr.tea.R;

import butterknife.BindView;
import butterknife.ButterKnife;

public class YuanChaWebActivity extends AppCompatActivity {

    @BindView(R.id.yuancha_web)
    WebView yuanchaWeb;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_yuan_cha_web);
        ButterKnife.bind(this);
        String url = getIntent().getStringExtra("url");
        setWebView();
        yuanchaWeb.loadUrl(url);
    }

    private void setWebView() {
        WebSettings ws = yuanchaWeb.getSettings();
        ws.setJavaScriptEnabled(true);  //支持js
        ws.setPluginState(WebSettings.PluginState.ON);//设置是否支持插件
        ws.setUseWideViewPort(false);  //将图片调整到适合webview的大小
        ws.setSupportZoom(true);  //支持缩放
        ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); //支持内容重新布局
        ws.supportMultipleWindows();  //多窗口
        ws.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);  //关闭webview中缓存
        ws.setAllowFileAccess(true);  //设置可以访问文件
        ws.setNeedInitialFocus(true); //当webview调用requestFocus时为webview设置节点
        ws.setBuiltInZoomControls(true); //设置支持缩放
        ws.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
        ws.setLoadWithOverviewMode(true); // 缩放至屏幕的大小
        ws.setLoadsImagesAutomatically(true);  //支持自动加载图片
    }
}
